package com.sushe.service;

import com.sushe.dao.BedDao;
import com.sushe.dao.StudentDao;
import com.sushe.service.jiekou.StudentDeleteService;

import java.sql.SQLException;
import java.util.Scanner;

public class StudentDeleteServiceImpl implements StudentDeleteService {

    private StudentDao studentDao=new StudentDao();
    private BedDao bedDao=new BedDao();

    @Override
    public  void deleteStudent() throws SQLException, ClassNotFoundException {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入要删除学生的的姓名：");
        String studentName=sc.nextLine();
        Integer studentId= studentDao.getStudentId(studentName);
        //首先删除床位绑定信息
        bedDao.deleteStudentIdByStudentId(studentId);
        //然后删除学生信息
        studentDao.deleteStudentById(studentId);
    }
}
